<template name="sendcar">
	<!--组织移位申请列表 -->
	<view class="mypage">
		<!-- <dcustom bgColor="bg-blue" :isBack="true" :isArrow="true">
			<block slot="content">{{ title }}</block>
			<block slot="right">
				<view class="nav-right-wrap text-xl" @click="openDetailList(0)">
					<text class='cuIcon-roundadd'></text>
				</view>
			</block>
		</dcustom> -->

		<view class="cu-bar search bg-white">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input type="text" v-model="keyword" placeholder="输入单号" />
			</view>
			<view class="action">
				<button class="cu-btn bg-blue shadow-blur round">搜索</button>
			</view>
		</view>
		
		<view class="card-list-wrapper">
			<view class="card-list-row radius shadow-warp bg-white margin-top" v-for="(item,index) in planList" :key="index">
				
				<view class="flex-just-between bottom-border top-wrap">
					<text class="text-blue text-bold">{{ label01 }}：{{ item.BILLNO }}</text>
					<view class="cu-capsule radius">
						<view class='cu-tag bg-blue sm'>
							<text class='cuIcon-medal'></text>
						</view>
						<view class="cu-tag line-brown sm">
							{{ index+1}}
						</view>
					</view>
				</view>
				
				<view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text class="card-label text-black">集团：</text>
					<text>{{ item.GROUPNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text class="card-label text-black">移出组织：</text>
					<text>{{ item.ORGNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-green"></text>
					<text class="card-label text-black">移出仓库：</text>
					<text>{{ item.STORENAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-blue"></text>
					<text class="card-label text-black">申请人：</text> 
					<text>{{ item.MOVER || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-blue"></text>
					<text class="card-label text-black">移入组织：</text> 
					<text>{{ item.INORGNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-green"></text>
					<text class="card-label text-black">移入仓库：</text>
					<text>{{ item.INSTORENAME || '' }}</text>
				</view>
			
				<view class="card-list-row-1">
					<text class="cuIcon-title text-blue"></text>
					<text class="card-label text-black">制单人：</text> 
					<text>{{ item.BILLMAKER || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-gray"></text>
					<text class="card-label text-black">日期：</text> 
					<text>{{ item.BILLDATE || '' }}</text>
				</view>			
			</view>
		
		</view>
		
	</view>

</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import api from '@/common/api.js'
	let _self, page=1, total=1, originalTitle,type;
	let query = {
			"category":"", 
			"page":1,
			"rows":5,
			"sidx":"",
			"sord":"",
			"queryJson":{BTYPE:3},
			"userId":"",
			"account":"admin"
	}
	export default {
		computed: mapState(['userInfo','baseUrl']),
		data() {
			return {
				title:'列表',
				planList: [],
				label01: '订单'
			};
		},
		onLoad(params) {
			
			var datalist= params.n;
			
			var t=datalist.split(",");
		
			_self = this; 
			_self.title = t[0] + '列表';
			console.log(_self.title);
			originalTitle =  t[0] + '列表'
			type = params.mt 
			page = 1;
			total = 1 ;
			console.log(params)
			switch (params.mt){
				case "M1016":
					query.category = 'BILLNO'; 
					_self.label01 = '单据编号'
					break;				
				default:
					break;
			}
			
			// url = params.t == "M1001"? api.apiPublic.M1001List: api.apiPublic.M1003List
			this.getNewsList();
			// console.log(params);
			
		},
		//下拉刷新
		onPullDownRefresh : function(){
			// 重置分页及数据
			page = 1;
			total = 1 ;
			this.getNewsList();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
			uni.showToast({"title":"数据已刷新", icon:"none"});
		},
		// 加载更多
		onReachBottom : function(){
			this.getNewsList();
		}, 
		onNavigationBarButtonTap() {
			this.openDetailList(0)
		},
		methods:{
			getNewsList(){
				if(page>total){return uni.showToast({
					icon:'none',
					title:'没有数据了。'
				})}
				query.page = page ;
				 console.log(query);
				 console.log(_self.baseUrl + api.apiPublic.DisplacementList);
				 this.axios({
				 	url: api.apiPublic.DisplacementList ,
				 	data: query ,
				 	isLoading: 1
				 }).then(res=>{
				 	let { Result } = res ;
				 	if( page == 1){
				 		_self.planList = res.rows
				 		_self.title = originalTitle + '('+res.records +')'
				 	}else{
				 		_self.planList = _self.planList.concat(res.rows)
				 	}
				 	total = res.total
				 	page++
				 })
			},
			openDetailList:function(e){
				 console.log(e);
				 let path = '/pages/tab04/submit3';
				// let url = '/pages/tab04/submit3?id=' 
				//   + _self.planList[e].BILLNO +'&dbt='
				// 	+ query.category +'&t='+type+'&item='+encodeURIComponent(JSON.stringify(_self.planList[e]));
				uni.navigateTo({
					url:  path 
				})
			}
		}
	}
</script>

<style scoped>
	
	.card-list-wrapper {
		width: 710upx;
		height: 100upx;
		margin: 0 auto;
	}

	.card-list-row {
		padding: 20upx;
	}

	.card-list-row-1 {
		padding: 10upx 0;
	}
	.card-label{
		display: inline-block;
		width: 150upx;
	}
	.top-border{
		border-top: 1upx solid rgba(0,0,0,.1);
	}
	.top-wrap{
		padding-bottom: 20upx;
		margin-bottom: 20upx;
	}
	.bottom-border{
		border-bottom: 1upx solid rgba(0,0,0,.1);
	}
	.btn-wrap{
		padding-top: 20upx;
	}
</style>
